package de.bloxel;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import com.jme3.system.AppSettings;

import de.bloxel.ui.BloxelApplication;
import de.bloxel.ui.BloxelApplicationSettingsProvider;
import de.bloxel.world.OpenWorldTerrainChunk;
import de.bloxel.world.PlaneTerrainLoader;
import de.bloxel.world.TerrainChunk;
import de.bloxel.world.TerrainLoader;

/**
 * This {@link Configuration} class glues the application together.
 * 
 * @author Klaus Hauschild
 * @since 0.1.0
 */
@Configuration
public class BloxelConfiguration {

  @Bean
  public BloxelApplication bloxelApplication() {
    return new BloxelApplication(bloxelApplicationSettingsProvider(), terrainChunk());
  }

  @Bean
  public BloxelApplicationSettingsProvider bloxelApplicationSettingsProvider() {
    return new BloxelApplicationSettingsProvider(defaultSettings());
  }

  @Bean
  public AppSettings defaultSettings() {
    final AppSettings appSettings = new AppSettings(true);
    appSettings.setResolution(800, 600);
    appSettings.setTitle("Bloxel");
    appSettings.setSettingsDialogImage("/de/bloxel/ui/settingsDialogImage.png");
    return appSettings;
  }

  @Bean
  public TerrainChunk terrainChunk() {
    return new OpenWorldTerrainChunk(terrainLoader(), 4);
    // return new TerrainChunkImpl2(terrainLoader(), 8);
  }

  @Bean
  public TerrainLoader terrainLoader() {
    // return new DemoTerrainLoader();
    return new PlaneTerrainLoader();
    // return new FillTerrainLoader();
  }
}
